//
//  RankListModel.swift
//  MM2
//
//  Created by 李成明 on 2022/1/7.
//

import UIKit

class RankListModel: BaseModel {

    var userId: Int = 0
    var userName: String = ""
    var avatar: String = ""
    var faceValue: Float = 0.0
    var gender: Int = 0
    var age: Int = 0
    var smile: Float = 0
    var emotion: Int = 0
    var skinHealth: Float = 0
    var skinStain: Float = 0
    var skinAcne: Float = 0
    var skinDarkCircle: Float = 0

    var isTop: Bool = false       /// 是否是前十
    var imgUrl: String = ""    ///isTop为true 返回imgUrl 如果为false 返回空串
    
    var rankNum: Int = 0    /// 排名
    
    func getValueArray() -> [FaceAnalyzeResultType] {
        return [.gender(value: gender), .age(value: age), .smile(value: smile), .emotion(value: emotion), .skinHealth(value: skinHealth), .skinStain(value: skinStain), .skinAcne(value: skinAcne), .skinDarkCircle(value: skinDarkCircle)]
    }
}

extension RankListModel: Comparable {
    static func < (lhs: RankListModel, rhs: RankListModel) -> Bool {
        if lhs.isTop != rhs.isTop {
            return rhs.isTop
        } else {
            return lhs.faceValue < rhs.faceValue
        }
    }
    
    static func == (lhs: RankListModel, rhs: RankListModel) -> Bool {
        return lhs.isTop == rhs.isTop && lhs.faceValue == rhs.faceValue
    }
}
